package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhSupplierdes;
import com.ruoyi.xh.service.IXhSupplierdesService;

/**
 * 入住明细Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "入住明细Controller",value = "入住明细Controller")
@RestController
@RequestMapping("/xh/supplierdes")
public class XhSupplierdesController extends BaseController {

    @Autowired
    private IXhSupplierdesService xhSupplierdesService;

    /**
     * 查询入住明细列表
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdes:list')")
    @GetMapping("/list")
    @ApiOperation("查询入住明细列表")
    public TablePageDataInfo<XhSupplierdes> list(XhSupplierdes xhSupplierdes) {
        return TablePageDataInfo.success(xhSupplierdesService.selectXhSupplierdesList(xhSupplierdes));
    }

    /**
     * 获取入住明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdes:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取入住明细详细信息")
    public CommentResult<XhSupplierdes> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhSupplierdesService.selectXhSupplierdesById(id));
    }

    /**
     * 新增入住明细
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdes:add')")
    @Log(title = "入住明细", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增入住明细")
    public CommentResult<XhSupplierdes> add(@RequestBody XhSupplierdes xhSupplierdes) {
            xhSupplierdesService.insertXhSupplierdes(xhSupplierdes);
        return CommentResult.success();
    }

    /**
     * 修改入住明细
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdes:edit')")
    @Log(title = "入住明细", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改入住明细")
    public CommentResult<XhSupplierdes> edit(@RequestBody XhSupplierdes xhSupplierdes) {
            xhSupplierdesService.updateXhSupplierdes(xhSupplierdes);
        return CommentResult.success();
    }

    /**
     * 删除入住明细
     */
    @PreAuthorize("@ss.hasPermi('xh:supplierdes:remove')")
    @Log(title = "入住明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除入住明细")
    public CommentResult<XhSupplierdes> remove(@PathVariable Long[] ids) {
            xhSupplierdesService.deleteXhSupplierdesByIds(ids);
        return CommentResult.success();
    }
}
